package com.bolt.admin.module.quartz.controller;

import com.bolt.admin.module.quartz.dto.JobLogDTO;
import com.bolt.admin.module.quartz.dto.converter.JobLogConverter;
import com.bolt.admin.module.quartz.entity.JobLogEntity;
import com.bolt.admin.module.quartz.service.JobLogService;
import com.bolt.convention.data.PageInfo;
import com.bolt.convention.data.ResultMessage;
import com.bolt.convention.data.Returns;
import com.bolt.support.spring.jpa.specification.QueryHelp;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/sys/quartz/log")
@RequiredArgsConstructor
@Api(description = "定时任务日志管理")
public class JobLogController {

    private final JobLogService logService;

    /**
     * 定时任务日志列表分页
     *
     * @return
     */
    @GetMapping
    public ResultMessage list(Pageable pageable, JobLogDTO dto) {
        PageInfo<JobLogEntity> pageInfo = logService.findPage(pageable, (root, criteriaQuery, criteriaBuilder)
                -> QueryHelp.getPredicate(root, dto, criteriaBuilder));
        return Returns.success(pageInfo.map(K -> JobLogConverter.toDTO(K)));
    }
}

 